﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.Master" AutoEventWireup="true" CodeBehind="AdminPage.aspx.cs" Inherits="WeakEndForum.WebForm1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="body" runat="server">
    <div class="container">
        <div class="page-header">
            <span class="h2 RalewayFont"><span class="glyphicon glyphicon-cog"></span> Administration des utilisateurs</span>
        </div>

        <asp:GridView ID="gridUsers" CssClass="table table-bordered"  runat="server" AutoGenerateColumns="False" DataSourceID="dataUsers" DataKeyNames="Username">
            <Columns>
                <asp:BoundField DataField="Username" HeaderText="Username" ReadOnly="True" SortExpression="Username"></asp:BoundField>
                <asp:BoundField DataField="Email" HeaderText="Email" ReadOnly="true" SortExpression="Email"></asp:BoundField>
                <asp:CheckBoxField DataField="Moderateur" HeaderText="Moderateur" SortExpression="Moderateur"></asp:CheckBoxField>
                <asp:CheckBoxField DataField="Admin" HeaderText="Admin" SortExpression="Admin"></asp:CheckBoxField>
                <asp:CheckBoxField DataField="Ban" HeaderText="Ban" SortExpression="Ban"></asp:CheckBoxField>
                <asp:CommandField ControlStyle-CssClass="btn btn-primary" ShowEditButton="True"></asp:CommandField>
            </Columns>
        </asp:GridView>

        <asp:SqlDataSource runat="server" ID="dataUsers" ConnectionString='<%$ ConnectionStrings:ForumUsersDatabase %>' DeleteCommand="DELETE FROM [Utilisateurs] WHERE [Username] = ?" InsertCommand="INSERT INTO [Utilisateurs] ([Username], [Email], [Moderateur], [Admin], [Ban]) VALUES (?, ?, ?, ?, ?)" ProviderName='<%$ ConnectionStrings:ForumUsersDatabase.ProviderName %>' SelectCommand="SELECT [Username], [Email], [Moderateur], [Admin], [Ban] FROM [Utilisateurs]" UpdateCommand="UPDATE [Utilisateurs] SET [Moderateur] = ?, [Admin] = ?, [Ban] = ? WHERE [Username] = ?">
            <DeleteParameters>
                <asp:Parameter Name="Username" Type="String"></asp:Parameter>
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="Username" Type="String"></asp:Parameter>
                <asp:Parameter Name="Email" Type="String"></asp:Parameter>
                <asp:Parameter Name="Moderateur" Type="Boolean"></asp:Parameter>
                <asp:Parameter Name="Admin" Type="Boolean"></asp:Parameter>
                <asp:Parameter Name="Ban" Type="Boolean"></asp:Parameter>
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="Moderateur" Type="Boolean"></asp:Parameter>
                <asp:Parameter Name="Admin" Type="Boolean"></asp:Parameter>
                <asp:Parameter Name="Ban" Type="Boolean"></asp:Parameter>
                <asp:Parameter Name="Username" Type="String"></asp:Parameter>
            </UpdateParameters>
        </asp:SqlDataSource>
    </div>

    </asp:Content>
